<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script type="">
    //抽象类 不能创建实例（不能new Animal） 一般是当作父类  只用于继承 
    //abstract 只用于ts文件
    abstract class Animal{
        constructor(name){
          this.name = "name"
        }
        abstract say()  //表示通过Animal继承的子类中必须从写say方法
    }





    //类
    class Person1 {
      sex='man' //实例属性  new之后可以直接访问 （new Person1.name）
      static name="person" //静态属性  只能通过类访问 （Person1.name）
        constructor() {
          this.age = "11"
        }
        static say(){    //静态方法  只能通过类访问 （Person1.say()）
          console.log(this.name)
        }
        say1(){
          console.log(this.name)
        }
      }





    function Car (name,color) {
      this.name = name,
      this.color = color,
      this.size = "big";
    }
      var car = new Car('bmw','red');
      var car2= new Car('bc','blue');


      class Person {
        constructor(name,age) {
          this.name = name;
          this.age = age
        }
        say(){
          console.log(this.name)
        }
      }

      let Person1 = new Person("John",11);
      //继承   
      class Teacher extends Person {
        //复杂写法
        constructor(name,age,code) {
          super(name,age);  //super就是父类  super()表示调用父类中的constructor
          this.code = code 
        }
        say(){
          console.log('hi world ');  //与父类重名  则表示重写方法
        }
        abc(){}
      }
      let t1 = new Teacher("小黄",3,110)



      class Test {
        static gan = 23
        
        gan2 = 45
        static gan3(){
          console.log(this.gan);
        }
      }
       Test.gan3()
      console.log((new Test()).gan3(),Test.gan);

      class Test2 {
        #name = 11
        gan2 = 45
        gan3(){
          console.log(this.#name);
        }
      }
      console.log(new Test2().gan3(),Test2);
      





      

  </script>
</body>
</html>